package blackhouse_server;

import java.sql.SQLException;
import java.util.List;

import blackhouse_dao.classtableDao;
import blackhouse_entity.classtable;

public class seeclassServer
{
	classtableDao	dao	= new classtableDao();

	public List<classtable> getClassInfo(String seek) throws SQLException
	{
		String sql = "SELECT * FROM classtable a LEFT JOIN grade b ON a.`gradeID` = b.`id`";
		if (seek != null)
		{
			if (!seek.trim().equals(""))
				sql += "where className LIKE '%" + seek + "%'";
		}
		return dao.findClassInfo(sql);
	}

	public boolean delclassinfo(int key, String name)
	{
		String sql = null;
		if (!name.equals("") && name != null)
		{
			sql = "UPDATE classtable SET className = '" + name
					+ "'  WHERE id = " + key;
		} else
		{
			sql = "DELETE FROM classtable WHERE id =" + key;
		}
		return dao.deldao(sql) > 0;
	}
}
